package com.ruihu.admin.module.business.log.interfacelog.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruihu.admin.common.domain.PageResultDTO;
import com.ruihu.admin.common.domain.ResponseDTO;
import com.ruihu.admin.module.business.log.interfacelog.dao.ElectricUpdateMessageQueueDao;
import com.ruihu.admin.module.business.log.interfacelog.domain.dto.ElectricUpdateMessageQueueAddDTO;
import com.ruihu.admin.module.business.log.interfacelog.domain.dto.ElectricUpdateMessageQueueUpdateDTO;
import com.ruihu.admin.module.business.log.interfacelog.domain.dto.ElectricUpdateMessageQueueQueryDTO;
import com.ruihu.admin.module.business.log.interfacelog.domain.entity.ElectricUpdateMessageQueueEntity;
import com.ruihu.admin.module.business.log.interfacelog.domain.vo.ElectricUpdateMessageQueueVO;
import com.ruihu.admin.module.business.log.interfacelog.domain.vo.ElectricUpdateMessageQueueExcelVO;
import com.ruihu.admin.util.PageUtil;
import com.ruihu.admin.util.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * [  ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c)  瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date 2023-02-08 15:53:41
 * @since JDK1.8
 */
@Service
public class ElectricUpdateMessageQueueService {

    @Autowired
    private ElectricUpdateMessageQueueDao electricUpdateMessageQueueDao;

    /**
     * 根据id查询
     */
    public ElectricUpdateMessageQueueEntity getById(Long id){
        return  electricUpdateMessageQueueDao.selectById(id);
    }

    /**
     * 分页查询
     * @author Tony
     * @date 2023-02-08 15:53:41
     */
    public ResponseDTO<PageResultDTO<ElectricUpdateMessageQueueVO>> queryByPage(ElectricUpdateMessageQueueQueryDTO queryDTO) {
        Page page = PageUtil.convert2QueryPage(queryDTO);
        List<ElectricUpdateMessageQueueVO> voList = electricUpdateMessageQueueDao.queryByPage(page, queryDTO);
        page.setRecords(voList);
        PageResultDTO<ElectricUpdateMessageQueueVO> pageResultDTO = PageUtil.convert2PageResult(page);
        return ResponseDTO.succData(pageResultDTO);
    }

    /**
     * 添加
     * @author Tony
     * @date 2023-02-08 15:53:41
     */
    public ResponseDTO<String> add(ElectricUpdateMessageQueueAddDTO addDTO) {
        ElectricUpdateMessageQueueEntity entity = BeanUtil.copy(addDTO, ElectricUpdateMessageQueueEntity.class);
        electricUpdateMessageQueueDao.insert(entity);
        return ResponseDTO.succ();
    }

    /**
     * 编辑
     * @author Tony
     * @date 2023-02-08 15:53:41
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> update(ElectricUpdateMessageQueueUpdateDTO updateDTO) {
        ElectricUpdateMessageQueueEntity entity = BeanUtil.copy(updateDTO, ElectricUpdateMessageQueueEntity.class);
        electricUpdateMessageQueueDao.updateById(entity);
        return ResponseDTO.succ();
    }

    /**
     * 删除
     * @author Tony
     * @date 2023-02-08 15:53:41
     */
    @Transactional(rollbackFor = Exception.class)
    public ResponseDTO<String> deleteByIds(List<Long> idList) {
        electricUpdateMessageQueueDao.deleteByIdList(idList);
        return ResponseDTO.succ();
    }

    /**
     * 查询全部导出对象
     * @author Tony
     * @date 2023-02-08 15:53:41
     */
    public List<ElectricUpdateMessageQueueExcelVO> queryAllExportData(ElectricUpdateMessageQueueQueryDTO queryDTO) {
        return electricUpdateMessageQueueDao.queryAllExportData( queryDTO);
    }

    /**
     * 批量查询导出对象
     * @author Tony
     * @date 2023-02-08 15:53:41
     */
    public List<ElectricUpdateMessageQueueExcelVO> queryBatchExportData(List<Long> idList) {
        return electricUpdateMessageQueueDao.queryBatchExportData(idList);
    }
}
